package com.xmy.cultivate.entity.response;

import com.xmy.cultivate.entity.CourseSchedulingDetail;
import com.xmy.cultivate.entity.RecordCourse;
import com.xmy.cultivate.enums.RecruitStatusEnum;
import org.apache.poi.hssf.record.Record;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
public class UserSort {
    public static void sortByData(List<RecordCourse> userList) {
        // 使用Comparator接口实现自定义排序
        Collections.sort(userList, new Comparator<RecordCourse>() {
            @Override
            public int compare(RecordCourse o1, RecordCourse o2) {
                // 将data转换为日期类型进行比较
                SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
                try {
                    Date date1 = sdf.parse(o1.getTimeStart());
                    Date date2 = sdf.parse(o2.getTimeStart());
                    return date1.compareTo(date2);
                } catch (ParseException e) {
                    e.printStackTrace();
                }
                return 0;
            }
        });
    }
    public static void sortByCourse(List<CourseSchedulingDetail> userList) {
        // 使用Comparator接口实现自定义排序
        Collections.sort(userList, new Comparator<CourseSchedulingDetail>() {
            @Override
            public int compare(CourseSchedulingDetail o1, CourseSchedulingDetail o2) {
                // 将data转换为日期类型进行比较
                SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
                try {
                    Date date1 = sdf.parse(o1.getTimeStart());
                    Date date2 = sdf.parse(o2.getTimeStart());
                    return date1.compareTo(date2);
                } catch (ParseException e) {
                    e.printStackTrace();
                }
                return 0;
            }
        });
    }
}